/**
 * @description 公共api
 */

import { http } from '../http'

const { get, put, post, delete: del } = http

// 系统模块
export const loginApi = {
  bindingLogin: post('/spa/authorization/v1/binding'), // 微信绑定登录
  getKaptcha: get('/spa/authorization/v1/kaptcha'), // 获取图形验证码
  sendSms: post('/spa/authorization/v1/sendSms'), // 发送短信验证码
  loginPwd: post('/spa/authorization/v1/login'), // 账号登录
  loginCode: post('/spa/authorization/v1/loginCode'), // 短信验证码登录
  wxCallback: post('/spa/authorization/v1/wxCallback'), // 微信回调
  generateWxQrCode: get('/spa/authorization/v1/generateWxQrCode'), //生成二维码
  checkVerifyCode: post('/spa/authorization/v1/checkVerifyCode'), // 校验图形验证码
  checkSmsCode: post('/spa/authorization/v1/checkSmsCode'), // 校验短信验证码
  forgetPassword: post('/spa/authorization/v1/forgetPassword'), // 忘记密码-设置密码
  logout: post('/spa/authorization/v1/logout'), // 注销登录
  // 注册
  register: post('/spa/authorization/v1/register')
}

// 下载任务管理
export const downloadTaskListApi = {
  getDownList: get('/spa/data/v1/sys-download-record'),
  delDownRecord: (id: string) => del(`/spa/data/v1/sys-download-record/${id}`),
  delDownRecords: del(`/spa/data/v1/sys-download-record`)
}

export const minioApi = {
  upload: (fileName: string, suffixVerify?: string) =>
    post(`/cloud/oss/minio/v2/presigned-upload`)({
      fileName: fileName,
      suffixVerify: suffixVerify || ''
    }),
  // put(`/cloud/oss/minio/presigned-upload?fileName=${fileName}${suffixVerify ? `&suffixVerify=${suffixVerify}` : ''}`)({}),
  download: get('/cloud/oss/minio/presigned-download'),
  checkFile: get('/cloud/oss/minio/presigned-status')
}

// GSelectTreeData组件相关接口
export const selectTreeDataApi = {
  dataBucketTree: get('/spa/data/v1/bucket/user/infoList'), // 数据集树列表
  collectDataBucketTree: get('/spa/data/v1/bucket/favorite/infoList'), // 收藏数据集树列表
  searchBucketList: get('/spa/data/v1/bucket/user/getByName'), // 数据集搜索
  collectSearchBucketList: get('/spa/data/v1/bucket/favorite/getByName'), // 收藏数据集搜索

  modelTree: get('/spa/data/v1/model-base/tree'), // 模型库树列表
  collectModelTree: get('/spa/data/v1/commom-model/favorite'), // 收藏模型库树列表
  searchModelList: get('/spa/data/v1/model-base/name'), // 模型库搜索
  collectSearchModelList: get('/spa/data/v1/commom-model/getFavoriteByName') // 收藏模型库搜索
}

// RadioTreeData组件相关接口
export const radioTreeDataApi = {
  //模型库列表（树）
  modelTree: get('/spa/data/v1/model-base/train/list'),
  //模型库搜索
  searchModel: get('/spa/data/v1/model-base/train/name')
}

// k8s调度相关
export const k8sApi = {
  //任务运行实时日志
  log: get('/cloud/scheduler/v1/kube/log')
}
